<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>随便打TCS系统</title>

    <!-- Bootstrap -->
    <link href="<%=basePath%>vendors/bootstrap/dist/css/bootstrap.min.css"
          rel="stylesheet">
    <!-- Font Awesome -->
    <link
            href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
            rel="stylesheet">
    <!-- NProgress -->
    <link href="<%=basePath%>vendors/nprogress/nprogress.css"
          rel="stylesheet">
    <!-- iCheck -->
    <link href="<%=basePath%>vendors/iCheck/skins/flat/green.css"
          rel="stylesheet">
    <script src=></script>
    <link href="<%=basePath%>vendors/layui/css/layui.css"
          rel="stylesheet">

    <!-- bootstrap-progressbar -->
    <link
            href="<%=basePath%>vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css"
            rel="stylesheet">
    <!-- JQVMap -->
    <link href="<%=basePath%>vendors/jqvmap/dist/jqvmap.min.css"
          rel="stylesheet"/>
    <!-- bootstrap-daterangepicker -->
    <link
            href="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.css"
            rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="<%=basePath%>build/css/custom.min.css" rel="stylesheet">

</head>
<body class="nav-md">
<div class="container body">
    <div class="main_container">
        <div class="col-md-3 left_col">
            <div class="left_col scroll-view">
                <div class="clearfix"></div>
                <br/>
            </div>
        </div>
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">
                <div class="clearfix"></div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_content">
                                <span class="section">支付宝或微信收款码配置</span>
                                <form name="myForm" class="form-horizontal form-label-left"
                                      novalidate method="post" enctype="multipart/form-data"
                                      id="myForm">
                                    <div class="item form-group" style="display: none">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12"
                                               for="name">id<span class="required"></span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="id" name="id"
                                                   class="form-control col-md-7 col-xs-12" type="text"
                                                   value="${usdtOnlinePay.id}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12"
                                               for="wechatImg">微信图片<span class="required">*</span>
                                            <button type="button" class="layui-btn" id="wechatImg">
                                                <i class="layui-icon">&#xe67c;</i>上传图片
                                            </button>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <div id="wximg" value="${usdtOnlinePay.wx}"
                                                 style="display: none"></div>
                                            <img src="${usdtOnlinePay.wx}" id="wxshow" height="200px"/>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12"
                                               for="alipayImg">支付宝图片<span class="required">*</span>
                                            <button type="button" class="layui-btn" id="alipayImg">
                                                <i class="layui-icon">&#xe67c;</i>上传图片
                                            </button>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <div id="aliimg" value="${usdtOnlinePay.alipay}"
                                                 style="display: none"></div>
                                            <img src="${usdtOnlinePay.alipay}" id="alishow" height="200px"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-md-6 col-md-offset-3">
                                            <input id="revise" onclick="update()" type="button" class="btn btn-success"
                                                   value="确定">
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /page content -->
    </div>
</div>
<!-- /page content -->
<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
<script src="<%=basePath%>vendors/layui/layui.js"></script>
<!-- Custom Theme Scripts -->
<script type="text/javascript">
    // layui.upload({
    //     url: '/layfile/uploadFile1'
    //     ,success: function(res, input){
    //         console.log(res); //如：{"code":0 ,"msg":"","url":"http://cdn.abc.com/123.jpg"'}
    //     }
    // });
    layui.use('upload', function () {
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#alipayImg' //绑定元素
            , url: '/SbdVoip/layfile/uploadFile1' //上传接口
            , done: function (res) {
                //上传完毕回调
                console.log(res)
                if (res.code == 0){
                    //上传完毕回调
                    $("#alishow").attr('src',res.data.src);
                    $("#aliimg").val(res.data.src)
                }
            }
            , error: function () {
                //请求异常回调
                alert("修改失败");
            }
        });
    });

    layui.use('upload', function () {
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#wechatImg' //绑定元素
            , url: '/SbdVoip/layfile/uploadFile1' //上传接口
            , done: function (res) {
                if (res.code == 2000){
                    //上传完毕回调
                    $("#wxshow").attr('src',res.data.src);
                    $("#wximg").val(res.data.src)
                    alert("修改成功");
                }
            }
            , error: function () {
                //请求异常回调
                alert("修改失败");
            }
        });
    });

   function update() {
       var zbfimg=$("#aliimg").val();
       var wximg=$("#wximg").val();
       $.ajax({
           type: 'POST',
           url: 'merchantCollectionImage/update',
           data: {
               alipay:zbfimg,
               wx:wximg
           },
           dataType: 'json',
           success: function (date) {
            console.log(date);
            if(date.errorCode == 2000){
                alert("修改成功");

            }
           },
           error: function () {
               alert("修改失败，请重新操作");
           }
       });
   }
    <%--});--%>
</script>
<!-- Bootstrap -->
<script src="<%=basePath%>vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="<%=basePath%>vendors/fastclick/lib/fastclick.js"></script>
<!-- NProgress -->
<script src="<%=basePath%>vendors/nprogress/nprogress.js"></script>
<!-- bootstrap-daterangepicker -->
<script src="<%=basePath%>vendors/moment/min/moment.min.js"></script>
<script
        src="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- Chart.js -->
<script src="<%=basePath%>vendors/Chart.js/dist/Chart.min.js"></script>
<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>

</body>
</html>